#! /usr/bin/env python
# -*- encoding:utf-8 -*-
# FileName: transfex.py

"This file is part of ____"
 
__author__   = "yetist"
__copyright__= "Copyright (C) 2011 yetist <wuxiaotian@redflag-linux.com>"
__license__  = """
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
import os
import sys

def main():
    sys.argv[0] = "tx"
    pofile = sys.argv[-1]
    if pofile.endswith(".po"):
        po = pofile[:-3] + "pot"
        cwd = os.path.basename(os.getcwd())
        if os.path.dirname(po) == "xmlpo":
            project = cwd + "-reference-manual." + "docs-%s" % os.path.basename(po)
        elif os.path.dirname(po) == "po":
            project = cwd + "-reference-manual." + "%s" % os.path.basename(po)
        sys.argv.insert(-1, "-r")
        sys.argv.insert(-1, project)
        sys.argv[-1] = pofile
        if "query" in sys.argv:
            print("-r", project)
            sys.exit(0)
    cmd = " ".join(sys.argv)
    os.system(cmd)
    if sys.argv[1] in ["help"]:
        print("\n", " query <POFILE>        Query the resource name\n")

if __name__=="__main__":
    main()
